package com.wcz.code.图形篇;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.Insets;

import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.border.Border;
import javax.swing.border.LineBorder;

import com.wcz.code.util.Common;

/**
 * @author 伪尘子
 *
 * 2012-6-18
 */
public class GraphicsTest extends JFrame{

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		
		GraphicsTest jf=new GraphicsTest();
		MyLab jl=new MyLab();
		jf.add(jl);
		jf.setVisible(true);
		
		jf.pack();
		jf.setDefaultCloseOperation(jf.EXIT_ON_CLOSE);
		
	}
	
	@Override
	public void print(Graphics g) {
		
	}
	
	

}

class MyLab extends JPanel{
	
	public MyLab() {
		setBorder(new LineBorder(Color.red, 4));
		this.add(new JLabel(new ImageIcon(Common.readImage("/root/image/carmera.gif"))));
//		this.setLayout(new BorderLayout());
	}
	
	/**
	 * 父容器会自动调用这个方法，提供Graphics
	 */
	public void paintComponent(Graphics g)
	{
		g.drawString(Common.getDate(),20, 30);
		g.setColor(Color.black);
		g.drawLine(100, 100, 400, 100);
		g.fillOval(0,0,30,30);
	}
	
}



